Dynomotion

Group: DynoMotion Message: 12191 From: jojodillinger Date: 9/1/2015
Subject: tool length probe
Dear all,

I am setting up a tool length probe in combination with a spindle with manual tool change.

I want to reserve a dummy slot in the tool table, in which I want to store the machine z position in the very first probe touch with the first milling cutter ( save it in the tool length field).
When starting to replace the cutter with other ones, I use the reference stored in the dummy slot to calculate the tool length for tool length compensation.

In the program I use
GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
to find out about the currently selected tool.

The following questions came up..

1) is TWORD an integer of the slot number?

2) in init-file, I want to hardcode to use tool id 1001 (slot 1) as default. What would be the appropriate function for that?

3) when writing
SetToolLength(TWORD,NewToolLength);
does this immediately affect the DRO (the one with G54)? Or do I have to activate somehow?

4) if TWORD is an integer of the slot, then I could define tool length of dummy slot 99 by
SetToolLength(99,NewToolLength);
Is that correct?

5) In KmotionCNC, I switched on "Tool Length/Offset immediately" on Trajectory Planner page. However, the compensation becomes only active in the DRO (G54), when I activate the tool by "G43 H1001" in gcode. Am I doing something wrong or is this a normal behavior?

6) finally, when using Move(x,x) in c-program, are soft limits active? This is just a safety question, since I might mess up the way I want to move the spindle to xyz of the probe..:)


Thanks a lot in advance!

Kind regards,

Johannes



PS the core of the probe-c-program should look something like this:

    GetMiscSettings(&Units, &TWORD, &HWORD, &DWORD);
    GetToolLength(TWORD,  &Length1);
    GetToolLength(99,          &Length2);
   
    if (Length2 == -50.0){
        /* this should happen only at first probe measurement;
           length of tool 1 set to 0.0 and length of tool 99 set to -50.0 in the init file
        */
        SetToolLength(99,znew/ZPULSEperMM);        // save the absolute machine z-position in mm
    }else{
        /* this should happen from second measurement on;
           tool length 1 is calculated relative to very first probe measurement
        */
        NewToolLength = znew/ZPULSEperMM - Length1;        // tool length is diff. between new and old abs. position
        SetToolLength(TWORD,NewToolLength);                // set the new toollength
    }


Group: DynoMotion Message: 12192 From: Tom Kerekes Date: 9/2/2015
Subject: Re: tool length probe
Hi  ,

Regarding:

#1 no it is neither the Slot or the ID it is the tool table Index

#2 not sure what you mean here

#3 it should immediately affect the DRO if that tool is currently selectedand tool length compensation is turned on

#4 that would affect tool table entry 99

#5 "Tool Length/Offset immediately" has to do with changing the Tool Dropdown, so yes that is the designed behavior

#6 yes Soft limits should always be active to whatever the Soft Limit Values in the Axis Parameters are configures to.

This assumes the later Test Versions are being used (some of this behavior has changed over time)

HTH
Regards
TK





Group: DynoMotion Message: 12195 From: Hardy Family Date: 9/2/2015
Subject: Re: tool length probe
Yes, that "TWORD" parameter in the samples confused me too.  Maybe you could rename it to "TINDEX" to avoid people thinking it's from the G-code T word.

On a related note, I had some circumstances when I needed to find out the tool table index for an arbitrary slot (or ID) number, but there was no PC command defined to do this.  So I added my own:

#define PC_COMM_SLOT_TO_INDEX 51      // Convert slot number to tool table index. persist+1 is persist index
                                         // for result, persist+2 is slot or tool ID to look up.

Regards,
SJH


On Wed, Sep 2, 2015 at 9:29 AM, Tom Kerekes tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi  ,

Regarding:

#1 no it is neither the Slot or the ID it is the tool table Index

#2 not sure what you mean here

#3 it should immediately affect the DRO if that tool is currently selectedand tool length compensation is turned on

#4 that would affect tool table entry 99

#5 "Tool Length/Offset immediately" has to do with changing the Tool Dropdown, so yes that is the designed behavior

#6 yes Soft limits should always be active to whatever the Soft Limit Values in the Axis Parameters are configures to.

This assumes the later Test Versions are being used (some of this behavior has changed over time)

HTH
Regards
TK





Group: DynoMotion Message: 12215 From: jojodillinger Date: 9/6/2015
Subject: Re: tool length probe
Dear Tom and SJH,

thanks a lot for you help and clarification!

Probe touching is working now (if someone is interested, let me know; I guess there might be more people using manual tool change and a touch probe?).

I am still not yet sure if and when I have to activate tool length compensation with
G43 H1001
or if this g-command will be deactivated again with something like
M30
or other g/m-code
So to be sure, I introduce the G43 a few more times:)

Kind regards,

Johannes
Group: DynoMotion Message: 12216 From: Hardy Family Date: 9/6/2015
Subject: Re: tool length probe
Hi Johannes,

The G-code interpreter is based on RS274-NGC.  According to the manual:

To end a program, program M2. To exchange pallet shuttles and then end a program, program
M30. Both of these commands have the following effects.
1. Axis offsets are set to zero (like G92.2) and origin offsets are set to the default (like G54).
2. Selected plane is set to CANON_PLANE_XY (like G17).
3. Distance mode is set to MODE_ABSOLUTE (like G90).
4. Feed rate mode is set to UNITS_PER_MINUTE (like G94).
5. Feed and speed overrides are set to ON (like M48).
6. Cutter compensation is turned off (like G40).
7. The spindle is stopped (like M5).
8. The current motion mode is set to G_1 (like G1).
9. Coolant is turned off (like M9).

This does not say whether tool length compensation is reset (like G49).  However, I would play it safe with M2 or M30 and assume that it was turned off, so you should program the G43 Hn every time.

Our machine application uses T97 to represent a touch probe.  Every time there is a T97 M6 to mount the probe, it is required to have a following G43 H97.  I think if you follow this rule (G43 follows M6) then you can't go wrong.

A bit off-topic, but G-code probing is very primitive and limited.  We defined a custom M code (M100) which runs a program in the kflop which is much more sophisticated than the basic linear probing available with RS274-NGC.  For example, we have a routine to probe 4 points around a sphere and compute the center of the sphere.  You could do that using G-code math - with enormous effort - but C is a whole lot more powerful (and intelligible!) so it is worth doing.  We transmit results back to the G-code program using g-code '#' variables, which the kflop can read and write.


Regards,
SJH


On Sun, Sep 6, 2015 at 3:23 PM, jojodillinger@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Dear Tom and SJH,

thanks a lot for you help and clarification!

Probe touching is working now (if someone is interested, let me know; I guess there might be more people using manual tool change and a touch probe?).

I am still not yet sure if and when I have to activate tool length compensation with
G43 H1001
or if this g-command will be deactivated again with something like
M30
or other g/m-code
So to be sure, I introduce the G43 a few more times:)

Kind regards,

Johannes


Group: DynoMotion Message: 12220 From: jojodillinger Date: 9/8/2015
Subject: Re: tool length probe
Hi SJH,

thanks for the very good explanation. Will implement the G43 then a bit more often, to be on the safe side.

I dont yet have experience with the custom M-codes in KmotionCNC or what they do. But will have a look at it!
I attached the tool-length code as I use it in combination with the following gcode, that is implemented when tool change is required:

...
...
M05              (stop spindle)
M0                (stop program)       
                    (here do manual tool change, then hit button to run tool length measurement, ...)
G43 H1001   (switch tool length compensation on!)
M3               (start spindle CW)
...
...

I run the c-code manually by a button in KMotionCNC.
Probably this is not the most elegant way, although it seems to work...

Kind regards,

Johannes
  @@attachment@@
Group: DynoMotion Message: 12223 From: Hardy Family Date: 9/8/2015
Subject: Re: tool length probe [1 Attachment]
I think it should just be a matter of specifying your C code to be run from M6 rather than the user button.  You could add the stop spindle command to the C code as well, and move up to safe Z.  One advantage of using M6 (rather than a user button) is that you can write some C code to pop up a dialog box on the PC.  Then you can press OK to proceed with the tool length measurement, or CANCEL to abort the G-code.

So, if you do that you can just program
T1001 M6 G43 H1001
and everything will be taken care of.

And since I'm the type of guy who likes to fix things that ain't broke:

I noticed with your code that you query the PC for the steps per mm for the axis.  There's nothing wrong with that except that it slows things down and is a bit complicated.  The way we do it is to program the kflop axis "output gain" settings so that there is a known amount of movement for a given command like Move().  For example, we use microns.  So to move 1mm we just use MoveRel(axis, 1000.0) for any axis.  But you could use mm directly by setting the output gain 1000 times higher.  This works because the kflop uses floating point.  Whatever you choose, don't ever change it, since there's no need.  Also use it on all your machines, because then you can use the same settings in KmotionCNC for all machines (e.g. 25400 steps per inch, regardless of the actual machine resolution).

Your machine might not be complex enough to warrant it, but we have a common function that we use while waiting for any move to complete.  Rather than directly waiting for CheckDone(), we call our function which not only tests CheckDone(), but also looks for any other trouble which might be brewing.  For example, our tool changer uses a pneumatic collet, so we need to check that air pressure is available.  If air pressure goes away while moving, we stop everything to avoid a crash.

I think it's a good idea to commonize all the "disaster tests" so that you don't forget one.  It doesn't hurt to test CheckDone() on all axes even if you are only moving one at a time.  It also makes it convenient when new functions are added.  In our case we use it to check for timeouts (move taking unexpectedly long time? - maybe program bug), check for "single stepping" when trying to debug a routine, checking crash sensor, and so on.

Finally, it is probably good practice to call WaitNextTimeSlice() instead of hard-looping the CPU:

while (!CheckDone(2)) WaitNextTimeSlice();                             // loop until motion completes

No big problem, but it will allow other threads to get more CPU if required.

Regards,
SJH


On Tue, Sep 8, 2015 at 6:16 AM, jojodillinger@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 
[Attachment(s) from jojodillinger@... [DynoMotion] included below]

Hi SJH,

thanks for the very good explanation. Will implement the G43 then a bit more often, to be on the safe side.

I dont yet have experience with the custom M-codes in KmotionCNC or what they do. But will have a look at it!
I attached the tool-length code as I use it in combination with the following gcode, that is implemented when tool change is required:

...
...
M05              (stop spindle)
M0                (stop program)       
                    (here do manual tool change, then hit button to run tool length measurement, ...)
G43 H1001   (switch tool length compensation on!)
M3               (start spindle CW)
...
...

I run the c-code manually by a button in KMotionCNC.
Probably this is not the most elegant way, although it seems to work...

Kind regards,

Johannes